package com.jiang.专题.贪心.Q605;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/03/06 1:11
 */
class Solution {
    public boolean canPlaceFlowers(int[] flowerbed, int n) {
        int i = 0, len = flowerbed.length;
        while (i < len) {
            if (flowerbed[i] == 1) {
                i += 2;
            } else if (i == len - 1 || flowerbed[i + 1] != 1) {
                i += 2;
                n--;
            } else {
                i += 3;
            }
        }

        return n <= 0;
    }
}
